﻿using AutoMapper;
using MediatR;
using WarehouseManagement.Application.Command.WarehouseTypeCommand;
using WarehouseManagement.Domain.DTO.WarehouseType;
using WarehouseManagement.Domain.Entity;
using WarehouseManagement.Infrstructre.Interface;
namespace WarehouseManagement.Application.CommandHandler.WareTypeCommandHandler
{
    /// <summary>
    /// 仓库类别修改
    /// </summary>
    public class UptWareTypeCommandHandler:IRequestHandler<UptwareTypeCommand, int>
    {


        private readonly IWareTypeRepository _repository;
         IMapper _mapper;

        public UptWareTypeCommandHandler(IWareTypeRepository repository, IMapper mapper)
        {
            _repository = repository;
            _mapper = mapper;
        }

        public async Task<int> Handle(UptwareTypeCommand request, CancellationToken cancellationToken)
        {
           
            return await _repository.UpdateAsync(_mapper.Map<WarehouseCategory>(request.uptDto));
             
        }
    }
}
